import { getAttactmentInfo, upload } from "@/api/system/attact/info";

/**
 * 上传接口
 * @param file 文件信息
 * @param type 上传方式
 * @param requestData 请求参数
 */
export const uploadRequest = async (file: any, type: any, requestData: any) => {
  const dataForm = new FormData();
  dataForm.append(type, file);
  for (let name in requestData) {
    dataForm.append(name, requestData[name]);
  }
  const response = await upload(dataForm);
  return response.data;
};

/**
 * 获取文件URL地址
 * @param attactmentInfoId 附加详情ID
 */
export const getFileUrl = async (attactmentInfoId: any) => {
  const { data } = await getAttactmentInfo(attactmentInfoId);
  if (data) {
    return data;
  }
  return "";
};
